package ca;

public class SituationalComponent {
	public double[][] individuals;
	public double[] individualFitness;
	
	public SituationalComponent(int nIndividuals, int nParameters) {
		
		this.individuals = new double[nIndividuals][nParameters];
		this.individualFitness = new double[nIndividuals];
	}
	
	public void initSituationalComponent(double[][] population, double[] fitness){
		for(int i = 0; i < population.length; i++){
			for(int j = 0; j < population[0].length; j++){
				this.individuals[i][j] = population[i][j];
			}
			this.individualFitness[i] = fitness[i];
		}
	}

	public double[][] getIndividuals() {
		return individuals;
	}

	public void setIndividuals(double[][] individuals) {
		this.individuals = individuals;
	}

	public double[] getIndividualFitness() {
		return individualFitness;
	}

	public void setIndividualFitness(double[] individualFitness) {
		this.individualFitness = individualFitness;
	}
	
	public void updateIndividualParameters(int i, double[] parameters){
		for(int k = 0; k < individuals[i].length; k++){
			individuals[i][k] = parameters[k];
		}
	}
	
	public void updateIndividualFitness(int i, double fitness){
		individualFitness[i] = fitness;
	}
	
	public void adjustSpace(double[][] population, double[] populationFitness){
		for(int i = 0; i < population.length; i++){
			int worstIndividualIndex = -1;
			double worstFitness = Double.MIN_VALUE;
			
			for(int j = 0; j < this.individuals.length; j++){
				if(this.individualFitness[j] > worstFitness ){
					worstIndividualIndex = j;
					worstFitness = this.individualFitness[j];
				}
			}
			
			if(populationFitness[i] < this.individualFitness[worstIndividualIndex]){
				
			}
		}
	}
}
